﻿#ifndef CLOSABLELISTWIDGETITEM_H
#define CLOSABLELISTWIDGETITEM_H

#include <QWidget>
#include <QLabel>
#include <QPushButton>
#include <QEnterEvent>
#include <QMouseEvent>
#include "components/FWidgets/FMenu/FMenu.h"

class ClosableListWidgetItem : public QWidget
{
    Q_OBJECT
public:
    explicit ClosableListWidgetItem(QWidget *parent = nullptr);

    void setIcon(const QIcon& icon);
    QIcon icon() const;
    void setText(const QString &text);
    QString text() const;

    FMenu* contextMenu() const;

signals:
    void closeRequested();
    void itemActivated();

protected:
    void contextMenuEvent(QContextMenuEvent *event) override;

protected:
    void showCloseButton(bool show);
    void enterEvent(QEvent *event) override;
    void leaveEvent(QEvent *event) override;
    bool eventFilter(QObject *watched, QEvent *event) override;

private:
    QLabel* m_labelIcon;
    QLabel* m_labelText;
    QPushButton* m_btnClose;
    FMenu* m_contextMenu;
};

#endif // CLOSABLELISTWIDGETITEM_H
